<?php
/**
 * Protoweb's base controller with base functionality
 */
include_once 'pwcontroller.php';

/**
 * The controller widget model
 *
 * Public controller methods are friendly urls thanks to {@link http://codeigniter.com
 * Codeigniter}.
 *
 * @author Gonzalez Federico, Viera Leonel
 * @package Protoweb
 * @subpackage controller
 */
class Components extends PwController 
{
    public function __construct() 
    {
        parent::__construct();
    } 

    public function get_design_view($componentID, $projectID)
    {
        $component = Component::getComponent($componentID, new Project($projectID));
        die($component->getDesignView());
    }

    public function properties() 
    {

        $projectID   = $this->input->post('projectID');
        $componentID = $this->input->post('componentID');
        $data        = $this->input->post('attributes');
        $component   = Component::getComponent($componentID, new Project($projectID));
        die('<form method="post" enctype="multipart/form-data">' .
            $component->getProperties($data) .
            '   <div class="control-group">
                    <button type="submit" class="btn btn-primary">Save</button>
                    <a id="remove-component" href="#" class="btn btn-danger">Remove</a>
                </div>
            </form>'
        );
    }

    public function save($componentID, $projectID)
    {
        $post      = $this->input->post();
        $component = Component::getComponent($componentID, new Project($projectID));
        die($component->getDesignView($post));
    }
} // class Components

/* End of file components.php */
/* Location: ./application/controllers/components.php */